of

public static Optional<Language> of(Locale locale)

Returns an Optional that contains the Language for the given Locale or an empty Optional if there is no Language associated with the language obtained from the given Locale.


public static Optional<Language> of(String language, String country)

Returns an Optional that contains the Language for the given language and country codes or an empty Optional if there is no Language associated with the specified language and country codes.

Use instead of of if there is a need to pass the new language codes instead of the old ones, because Locale internally converts the new language code passed to the constructor to the old one. There is a chance not to find a language for an old code, so if you want to be sure that the passed locale will not be converted, use this method with the required language and country codes.

A set of the new language codes that will be converted to the old ones in the Locale are specified in Locale.

Return

an Optional of Language for the given parameters or empty if there is no Language associated with the given parameters

Since

7.1

Parameters

language

language code

country

country code

See also